import QtQuick 1.1
import com.nokia.meego 1.0
import TransferUI 1.0

Item {
    id: transferControls

    property int estimate: estimateTextField.text
    property alias progress: progressSlider.value

    property Style platformStyle: LabelStyle {}

    signal markCancelledButtonClicked()
    signal markCompletedButtonClicked()
    signal markDoneButtonClicked()
    signal markFailureButtonClicked()
    signal markPausedButtonClicked()
    signal markResumedButtonClicked()
    signal setActiveButtonClicked()
    signal setPendingButtonClicked()

    onEstimateChanged: {
        estimateTextField.text = estimate;
    }

    Grid {
        id: controlButtonsGrid
        width: parent.width
        property int buttonWidth: (parent.width - spacing) / 2

        anchors {
            top: parent.top
            left: parent.left
            right: parent.right
        }

        columns: 2
        spacing: 10

        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Cancel"
            onClicked: transferControls.markCancelledButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Mark completed"
            onClicked: transferControls.markCompletedButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Mark done"
            onClicked: transferControls.markDoneButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Mark failure"
            onClicked: transferControls.markFailureButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Pause"
            onClicked: transferControls.markPausedButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Resume"
            onClicked: transferControls.markResumedButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Set active"
            onClicked: transferControls.setActiveButtonClicked();
        }
        Button {
            width: controlButtonsGrid.buttonWidth
            text: "Set pending"
            onClicked: transferControls.setPendingButtonClicked();
        }
    }

    Grid {
        id: labeledControlsGrid
        width: parent.width

        anchors {
            top: controlButtonsGrid.bottom
            left: parent.left
            right: parent.right
            topMargin: spacing
        }

        columns: 2
        spacing: 10

        Text {
            id: estimateLabel
            width: 150
            height: estimateTextField.height
            verticalAlignment: Text.AlignVCenter
            text: "Estimate"

            font {
                family: platformStyle.fontFamily
                pixelSize: platformStyle.fontPixelSize
            }
        }
        TextField {
            id: estimateTextField
            width: transferControls.width - labeledControlsGrid.spacing / 2
                   - estimateLabel.width
            validator: IntValidator {}
            inputMethodHints: Qt.ImhPreferNumbers

            onTextChanged: {
                var textAsNum = estimateTextField.text;
                transferControls.estimate = textAsNum;
            }
        }

        Text {
            width: estimateLabel.width
            height: progressSlider.height
            verticalAlignment: Text.AlignVCenter
            text: "Progress"

            font {
                family: platformStyle.fontFamily
                pixelSize: platformStyle.fontPixelSize
            }
        }
        Slider {
            id: progressSlider
            width: estimateTextField.width
            minimumValue: 0.0
            maximumValue: 1.0
        }
    }
}

// End of file.
